
<div id="min-height" style="min-height: 630px; height: 814px;"><div class="w980 pb90 fc minHeight">



    <div class="w220 bg_gray fl  pt30 tac pos_r">

        <a href="{:U('Index/Customer/face')}">
            <img title="点击头像编辑" src="__ROOT__{$userInfo['face']}" class="img-circular" height="200" width="200">
        </a>
        <h4 class="lh26 ft24 pt10">{$userInfo['username']}</h4>

        <div class="pb10 pt10 bottom-border-white">
            <a class="btn btn_gray3" href="{:U('Index/Customer/index')}">
                <span class="btn_lft"></span>
                <span class="btn_mid ">个人设置</span>
                <span class="btn_rgt"></span>
            </a>
            <a class="btn btn_gray3" href="{:U('Index/Customer/password')}">
                <span class="btn_lft"></span>
                <span class="btn_mid ">密码修改</span>
                <span class="btn_rgt"></span>
            </a>
        </div>
        <ul class="lhb_snav1 ft15 mt15 tal">


        </ul>
    </div>
        <div class="fr">
            <div class="zb_learning">
                <h2 class="lhb_tit1 ft18 mt15">密码修改</h2>
                <form action="" method="post" id="form1"  >
                    <dl class="zb_form_dl2">
                    <dt>原密码：</dt>
                    <dd>
                        <input type="password" maxlength="16" onfocus="hideError(1)" class="text_input text_wid2" name="oldPwd" id="oldPwd">
                        <em class="zb_style_ico zb_error" id="error11" style="display:none"></em>
                        <span class="zb_style_txt" id="error12" style="display:none"></span>
                        
                    </dd>
                    <dt>新密码：</dt>
                    <dd>
                        <input type="password" maxlength="16" onfocus="hideError(2)" class="text_input text_wid2" name="newPwd" id="newPwd">
                        <em class="zb_style_ico zb_error" id="error21" style="display:none"></em>
                        <span class="zb_style_txt" id="error22" style="display:none"></span>
                    </dd>
                    <dt>重复新密码：</dt>
                    <dd>
                        <input type="password" maxlength="16" onfocus="hideError(3)" class="text_input text_wid2" id="reNewPwd" name="reNewPwd">
                        <em class="zb_style_ico zb_error" id="error31" style="display:none"></em>
                        <span class="zb_style_txt" id="error32" style="display:none"></span>
                    </dd>                   
                    </dl>
                <div class="pop_ct_btn">
                    <span class="btn btn_blue2">
                        <span class="btn_lft"></span>
                        <!-- <span class="btn_mid white" onclick="submit()">提 交</span> -->
                        <span class="btn_mid white " id="submit" >提 交</span>
                        <span class="btn_rgt"></span>
                    </span>
                </div>  
                 </form>
            </div>
        </div>   
</div>
</div>
<script type="text/javascript">
$(function(){
    $('#submit').click(function(event) {
        //阻止表单默认提交事件
            // event.preventDefault();
        var info = $("#form1").serialize();
        $.ajax({
            type: "post",
            async: false, //同步执行
            url: "{:U('Index/Customer/pwdmodfiy')}",
            data: info,
            success:function (msg) { 
                alert(msg);
                if(msg == "保存成功" ){
                    window.location.href = "{:U('Index/Customer/password')}";
                }    
                
            },
            error: function () {
                alert("网络连接错误，请稍后再试");
            }
        });
    });
});
</script>
<script type="text/javascript">

function hideError(obj){
    if(obj == 1){
        $('#error11').hide();
        $('#error12').hide();
    }
    if(obj == 2){
        $('#error21').hide();
        $('#error22').hide();
    }
    if(obj == 3){
        $('#error31').hide();
        $('#error32').hide();
    }
}
var regex_space = /[ ]+/;
function valid(){
    var oldPwd = $('#oldPwd').val(); 
    var newPwd = $('#newPwd').val(); 
    var reNewPwd = $('#reNewPwd').val(); 
    if(oldPwd == '')
    {
        $('#error11').show();
        $('#error12').show();
        $('#error12').html('原密码不能为空');
        return false;
    }
    if(oldPwd.length < 6)
    {
        $('#error11').show();
        $('#error12').show();
        $('#error12').html('原密码不能小于6位');
        return false;
    }
    if(newPwd == '')
    {
        $('#error21').show();
        $('#error22').show();
        $('#error22').html('新密码不能为空');
        return false;
    }
    if(regex_space.test(newPwd))
    {
        $('#error21').show();
        $('#error22').show();
        $('#error22').html('密码不能含有空格');
        return false;
    }
    if(newPwd.length < 6)
    {
        $('#error21').show();
        $('#error22').show();
        $('#error22').html('新密码不能小于6位');
        return false;
    }
    if(newPwd != reNewPwd)
    {
        $('#error31').show();
        $('#error32').show();
        $('#error32').html('两次密码不一致');
        return false;
    }
    return true;
}
function submit(){
    if(valid()){
        $('form').submit();
    }
}
</script>

<script>
    function unbind(thirdType,openId){
        var nextPage=$("input[name='next_page']").val();
        var url="/thirdLoginCon/unbind?nextPage="+nextPage+"&uid="+openId+"&type="+thirdType;
        location.href=url;
    }
    function addbind(thirdType,type){
        var nextPage=$("input[name='next_page']").val();
        var kooNextPage='http://www.koo.cn/thirdLoginCon/callBack?bind='+type+'&nextPage='+nextPage;
        var koo_next_url=base64_encode(kooNextPage);
        //var koo_next_url=encodeURIComponent(koo_next);
        var url='http://login.koolearn.com/sso//requestToken.do?koo_next_page='+koo_next_url+'&type='+thirdType+'&f=www_third_denglu';
        location.href=url;
    }

    $(function(){
        $(".zb_learning").ontabs(".setting-nav li",".setting-wrapper > .box","cur","click");
    });
    function base64_encode(str){
        var c1, c2, c3;
        var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
        var i = 0, len= str.length, string = '';

        while (i < len){
            c1 = str.charCodeAt(i++) & 0xff;
            if (i == len){
                string += base64EncodeChars.charAt(c1 >> 2);
                string += base64EncodeChars.charAt((c1 & 0x3) << 4);
                string += "==";
                break;
            }
            c2 = str.charCodeAt(i++);
            if (i == len){
                string += base64EncodeChars.charAt(c1 >> 2);
                string += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
                string += base64EncodeChars.charAt((c2 & 0xF) << 2);
                string += "=";
                break;
            }
            c3 = str.charCodeAt(i++);
            string += base64EncodeChars.charAt(c1 >> 2);
            string += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
            string += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));
            string += base64EncodeChars.charAt(c3 & 0x3F)
        }
        return string;
    }

</script>
<script>
    loadform();
</script>
<script type="text/javascript">
    function valid(){
        var address = $('#address').val();
        if(address != '' && address.length < 5){
            $('#addressError').show();
            $('#addressErrorText').text('地址不能少于五个字');
            return false
        }
        return true;
    }
</script>
